package com.TwinBlade.PicturePassword;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap.CompressFormat;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.provider.MediaStore.Images.Media;
import android.view.Display;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.Button;
import java.io.File;
import java.io.FileOutputStream;

public class Image extends Activity
  implements View.OnClickListener
{
  private Button a;
  private Button b;

  @SuppressLint({"WorldWriteableFiles"})
  private Uri a(boolean paramBoolean)
  {
    File localFile = new File(getFilesDir(), "PhotoData.jpg");
    if (!localFile.exists());
    try
    {
      openFileOutput("PhotoData.jpg", 2).close();
      return Uri.fromFile(localFile);
    }
    catch (Exception localException)
    {
      while (true)
        Utilities.a(this, getString(2131296429), 4, true);
    }
  }

  private void a()
  {
    Intent localIntent = new Intent("android.intent.action.GET_CONTENT");
    localIntent.setType("image/*");
    startActivityForResult(localIntent, 1);
  }

  private void b()
  {
    Intent localIntent = new Intent(this, Crop.class);
    localIntent.putExtra("CropWallpaper", true);
    startActivityForResult(localIntent, 2);
  }

  private void c()
  {
    Display localDisplay = getWindowManager().getDefaultDisplay();
    int i = localDisplay.getWidth();
    int j = localDisplay.getHeight();
    Intent localIntent = new Intent("android.intent.action.PICK", MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    localIntent.setType("image/*");
    localIntent.putExtra("crop", "true");
    localIntent.putExtra("scale", true);
    localIntent.putExtra("aspectX", i);
    localIntent.putExtra("aspectY", j);
    localIntent.putExtra("return-data", false);
    localIntent.putExtra("output", a(false));
    localIntent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
    startActivityForResult(localIntent, 2);
  }

  protected void onActivityResult(int paramInt1, int paramInt2, Intent paramIntent)
  {
    super.onActivityResult(paramInt1, paramInt2, paramIntent);
    switch (paramInt1)
    {
    default:
      return;
    case 1:
      if ((paramInt2 == -1) && (paramIntent != null))
      {
        Intent localIntent = new Intent(this, Crop.class);
        localIntent.setData(paramIntent.getData());
        startActivityForResult(localIntent, 2);
        return;
      }
      Utilities.a(this, getString(2131296431), 4, true);
      return;
    case 2:
    }
    if (paramInt2 != -1)
    {
      Utilities.a(this, getString(2131296432), 4, true);
      setResult(0);
      return;
    }
    setResult(-1);
    finish();
  }

  public void onClick(View paramView)
  {
    switch (paramView.getId())
    {
    default:
      return;
    case 2131230743:
      a();
      return;
    case 2131230744:
    }
    b();
  }

  public void onCreate(Bundle paramBundle)
  {
    String str = PreferenceManager.getDefaultSharedPreferences(this).getString("ForceOrientation", "0");
    if (str.equals("0"))
      if (!Utilities.a())
        setRequestedOrientation(1);
    while (true)
    {
      super.onCreate(paramBundle);
      setContentView(2130903045);
      this.a = ((Button)findViewById(2131230743));
      this.b = ((Button)findViewById(2131230744));
      this.a.setOnClickListener(this);
      this.b.setOnClickListener(this);
      if (!bd.a(this))
        this.b.setEnabled(false);
      return;
      setRequestedOrientation(0);
      continue;
      if (str.equals("1"))
        setRequestedOrientation(1);
      else if (str.equals("2"))
        setRequestedOrientation(0);
    }
  }

  public boolean onCreateOptionsMenu(Menu paramMenu)
  {
    getMenuInflater().inflate(2130903046, paramMenu);
    return true;
  }

  public boolean onOptionsItemSelected(MenuItem paramMenuItem)
  {
    if (paramMenuItem.getItemId() == 2131230745)
    {
      c();
      return true;
    }
    return super.onOptionsItemSelected(paramMenuItem);
  }
}

/* Location:           D:\Studium\Bachelorarbeit\BA Marcus Wobig\BA\BA\Decompiler\PicturePassword APK\Programm\PicturePassword_dex2jar.jar
 * Qualified Name:     com.TwinBlade.PicturePassword.Image
 * JD-Core Version:    0.6.2
 */